#! /usr/bin/env python

from django.core.handlers.wsgi import WSGIHandler
from port_authority.handlers import HandlerBase
from cherrypy.wsgiserver import CherryPyWSGIServer
import sys

__all__ = ["WSGIServer"]

class WSGIServer(HandlerBase):

    def start(self, daemonize=True):
        super(WSGIServer, self).start(daemonize)
        self.server = CherryPyWSGIServer(
            (self.host, self.port), self.application)
        try:
            self.server.start()
        except (KeyboardInterrupt, SystemExit):
            self.server.stop()
